\hypertarget{classSpriteManager}{
\section{SpriteManager Class Reference}
\label{classSpriteManager}\index{SpriteManager@{SpriteManager}}
}


{\ttfamily \#include $<$SpriteManager.h$>$}\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSpriteManager_a82941ce284548c762f250220ea58f43c}{
void {\bfseries Init} ()}
\label{classSpriteManager_a82941ce284548c762f250220ea58f43c}

\item 
\hypertarget{classSpriteManager_abd70497163fb7b0d9cf7bc84ad7e4add}{
void {\bfseries Deinit} ()}
\label{classSpriteManager_abd70497163fb7b0d9cf7bc84ad7e4add}

\item 
void \hyperlink{classSpriteManager_a62d64bc26902245b617f7e738ce1fe1b}{AddResource} (string file)
\item 
\hypertarget{classSpriteManager_a35b9196b2e3d675cb874b48458fc729d}{
M2DNode \hyperlink{classSpriteManager_a35b9196b2e3d675cb874b48458fc729d}{AddNode} (string handle)}
\label{classSpriteManager_a35b9196b2e3d675cb874b48458fc729d}

\begin{DoxyCompactList}\small\item\em Adds an instance node to the internal multimap and returns a copy of it. \item\end{DoxyCompactList}\item 
void \hyperlink{classSpriteManager_a8495b0a9a6de0c8bdd0fe60f46d9e314}{DeleteSprite} (string sprite\_\-name)
\item 
\hypertarget{classSpriteManager_a55a2a727022449bfaaa2a680d4431564}{
void \hyperlink{classSpriteManager_a55a2a727022449bfaaa2a680d4431564}{ClearNodes} (string handle)}
\label{classSpriteManager_a55a2a727022449bfaaa2a680d4431564}

\begin{DoxyCompactList}\small\item\em Clears all the instance nodes using the given resource. \item\end{DoxyCompactList}\item 
\hypertarget{classSpriteManager_af9a3d082241930a426e06002c2351a16}{
pSprite \hyperlink{classSpriteManager_af9a3d082241930a426e06002c2351a16}{GetSprite} (string sprite\_\-name)}
\label{classSpriteManager_af9a3d082241930a426e06002c2351a16}

\begin{DoxyCompactList}\small\item\em Returns a pointer to a sprite. Used in lookup routines. \item\end{DoxyCompactList}\item 
\hypertarget{classSpriteManager_a1d691cab83ad499119a09c076e107b26}{
void \hyperlink{classSpriteManager_a1d691cab83ad499119a09c076e107b26}{Cleanup} ()}
\label{classSpriteManager_a1d691cab83ad499119a09c076e107b26}

\begin{DoxyCompactList}\small\item\em Clears all instance nodes that have no associated resource. Essentially a garbage collection function. \item\end{DoxyCompactList}\item 
void \hyperlink{classSpriteManager_a34407a9e6ebf2f1eef21050768769d95}{MapNode} (M2DNode node, string key)
\end{DoxyCompactItemize}
\subsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSpriteManager_aab85b707923274ebc59acb94f9e04ee2}{
static \hyperlink{classSpriteManager}{SpriteManager} $\ast$ {\bfseries Instance} ()}
\label{classSpriteManager_aab85b707923274ebc59acb94f9e04ee2}

\end{DoxyCompactItemize}
\subsection*{Public Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSpriteManager_a991c710279d884da6de3dc7267f484d6}{
GLfloat \hyperlink{classSpriteManager_a991c710279d884da6de3dc7267f484d6}{error\_\-color\_\-array} \mbox{[}3\mbox{]}}
\label{classSpriteManager_a991c710279d884da6de3dc7267f484d6}

\begin{DoxyCompactList}\small\item\em An array used to render error instances. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSpriteManager_a66a70338940b875340d6bf3fa01308ab}{
{\bfseries SpriteManager} (\hyperlink{classSpriteManager}{SpriteManager} const \&)}
\label{classSpriteManager_a66a70338940b875340d6bf3fa01308ab}

\item 
\hypertarget{classSpriteManager_a2e955a289b86110e33da5ea2bac3b5eb}{
\hyperlink{classSpriteManager}{SpriteManager} \& {\bfseries operator=} (\hyperlink{classSpriteManager}{SpriteManager} const \&)}
\label{classSpriteManager_a2e955a289b86110e33da5ea2bac3b5eb}

\end{DoxyCompactItemize}
\subsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSpriteManager_a1c77424ed84e626df83e096bed462a84}{
std::map$<$ string, pSprite $>$ \hyperlink{classSpriteManager_a1c77424ed84e626df83e096bed462a84}{sprites}}
\label{classSpriteManager_a1c77424ed84e626df83e096bed462a84}

\begin{DoxyCompactList}\small\item\em std::map$<$string, pSprite$>$ of cached sprite resources. \item\end{DoxyCompactList}\item 
std::multimap$<$ string, M2DNode, \hyperlink{structstrsrt}{strsrt} $>$ \hyperlink{classSpriteManager_a5156a8aad404a5c7f6b14183f1dd178b}{nodes}
\end{DoxyCompactItemize}
\subsection*{Static Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSpriteManager_af01da77cb82294d7c9eea41cfa15d869}{
static \hyperlink{classSpriteManager}{SpriteManager} $\ast$ {\bfseries m\_\-pInstance} = NULL}
\label{classSpriteManager_af01da77cb82294d7c9eea41cfa15d869}

\end{DoxyCompactItemize}
\subsection*{Friends}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSpriteManager_a0d669340e63fcad02cde401bbd5bcc23}{
class \hyperlink{classSpriteManager_a0d669340e63fcad02cde401bbd5bcc23}{Mob2DRenderer}}
\label{classSpriteManager_a0d669340e63fcad02cde401bbd5bcc23}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
\hyperlink{classSpriteManager}{SpriteManager}: This class holds and caches all available sprite resources and also caches all of the nodes in a multimap. The nice thing about the std::multimap is that automatically sorts its data, so if the Nodes are mapped in this class according to the name of the sprite resource they are associated with, all that is needed to cut down on texture binds is to iterate through the map like normal and simply check to make sure we would not be binding a texture that was already bound. \par
\par
 Nodes versus Sprites -\/ Sprites are only resources stored by the engine. They don't do much besides provide data. Nodes however are updated and read by the engine and provide indirect access to the sprite resources. 

\subsection{Member Function Documentation}
\hypertarget{classSpriteManager_a62d64bc26902245b617f7e738ce1fe1b}{
\index{SpriteManager@{SpriteManager}!AddResource@{AddResource}}
\index{AddResource@{AddResource}!SpriteManager@{SpriteManager}}
\subsubsection[{AddResource}]{\setlength{\rightskip}{0pt plus 5cm}void SpriteManager::AddResource (string {\em file})}}
\label{classSpriteManager_a62d64bc26902245b617f7e738ce1fe1b}
Creates a new sprite, inserts it into the map, and delegates responsibility of loading the data to the \hyperlink{classSprite}{Sprite} instance. \hyperlink{classSprite}{Sprite} is hashed based on the name defined in its definition. \hypertarget{classSpriteManager_a8495b0a9a6de0c8bdd0fe60f46d9e314}{
\index{SpriteManager@{SpriteManager}!DeleteSprite@{DeleteSprite}}
\index{DeleteSprite@{DeleteSprite}!SpriteManager@{SpriteManager}}
\subsubsection[{DeleteSprite}]{\setlength{\rightskip}{0pt plus 5cm}void SpriteManager::DeleteSprite (string {\em sprite\_\-name})}}
\label{classSpriteManager_a8495b0a9a6de0c8bdd0fe60f46d9e314}
Releases a texture and flags all nodes using the resource to return the error sprite and sets all nodes using this resource to display an error texture. \hypertarget{classSpriteManager_a34407a9e6ebf2f1eef21050768769d95}{
\index{SpriteManager@{SpriteManager}!MapNode@{MapNode}}
\index{MapNode@{MapNode}!SpriteManager@{SpriteManager}}
\subsubsection[{MapNode}]{\setlength{\rightskip}{0pt plus 5cm}void SpriteManager::MapNode (M2DNode {\em node}, \/  string {\em key})}}
\label{classSpriteManager_a34407a9e6ebf2f1eef21050768769d95}
Used to map an already existing node so that it can be rendered. The function will check against the sprites map to make sure that the node is being mapped to an existing key to avoid inefficient rendering. 

\subsection{Member Data Documentation}
\hypertarget{classSpriteManager_a5156a8aad404a5c7f6b14183f1dd178b}{
\index{SpriteManager@{SpriteManager}!nodes@{nodes}}
\index{nodes@{nodes}!SpriteManager@{SpriteManager}}
\subsubsection[{nodes}]{\setlength{\rightskip}{0pt plus 5cm}std::multimap$<$string, M2DNode, {\bf strsrt}$>$ {\bf SpriteManager::nodes}\hspace{0.3cm}{\ttfamily  \mbox{[}protected\mbox{]}}}}
\label{classSpriteManager_a5156a8aad404a5c7f6b14183f1dd178b}
std::multimap$<$string, Mob2DNode$>$ of all of the available rendering nodes. This allows for sorting of the sprite nodes and leads to fewer texture changes. It also allows iteration through a specific range of nodes to flag them for deletion for the purpose of garbage collection. 

The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
/home/orm/Projects/Mob2D/libMob2D/src/SpriteManager.h\item 
/home/orm/Projects/Mob2D/libMob2D/src/SpriteManager.cpp\end{DoxyCompactItemize}
